# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//bazel:pl_build_system.bzl", "pl_go_test")

go_library(
    name = "bridge",
    srcs = [
        "server.go",
        "vzconn_client.go",
        "vzinfo.go",
    ],
    importpath = "px.dev/pixie/src/vizier/services/cloud_connector/bridge",
    visibility = [
        "//src/e2e_test:__subpackages__",
        "//src/vizier:__subpackages__",
    ],
    deps = [
        "//src/api/proto/vizierpb:vizier_pl_go_proto",
        "//src/cloud/vzconn/vzconnpb:service_pl_go_proto",
        "//src/operator/apis/px.dev/v1alpha1",
        "//src/operator/client/versioned",
        "//src/shared/cvmsgs",
        "//src/shared/cvmsgspb:cvmsgs_pl_go_proto",
        "//src/shared/goversion",
        "//src/shared/k8s",
        "//src/shared/k8s/metadatapb:metadata_pl_go_proto",
        "//src/shared/services",
        "//src/shared/status",
        "//src/utils",
        "//src/utils/shared/k8s",
        "//src/vizier/messages/messagespb:messages_pl_go_proto",
        "//src/vizier/services/cloud_connector/vzmetrics",
        "//src/vizier/utils/messagebus",
        "@com_github_blang_semver//:semver",
        "@com_github_cenkalti_backoff_v4//:backoff",
        "@com_github_gofrs_uuid//:uuid",
        "@com_github_gogo_protobuf//proto",
        "@com_github_gogo_protobuf//types",
        "@com_github_nats_io_nats_go//:nats_go",
        "@com_github_sirupsen_logrus//:logrus",
        "@com_github_spf13_pflag//:pflag",
        "@com_github_spf13_viper//:viper",
        "@io_k8s_api//batch/v1:batch",
        "@io_k8s_api//core/v1:core",
        "@io_k8s_apimachinery//pkg/api/errors",
        "@io_k8s_apimachinery//pkg/apis/meta/v1:meta",
        "@io_k8s_apimachinery//pkg/fields",
        "@io_k8s_client_go//discovery",
        "@io_k8s_client_go//kubernetes",
        "@io_k8s_client_go//kubernetes/scheme",
        "@io_k8s_client_go//rest",
        "@io_k8s_client_go//tools/cache",
        "@org_golang_google_grpc//:grpc",
        "@org_golang_google_grpc//codes",
        "@org_golang_google_grpc//metadata",
        "@org_golang_google_grpc//status",
    ],
)

pl_go_test(
    name = "bridge_test",
    srcs = ["server_test.go"],
    deps = [
        ":bridge",
        "//src/api/proto/vizierpb:vizier_pl_go_proto",
        "//src/cloud/vzconn/vzconnpb:service_pl_go_proto",
        "//src/operator/apis/px.dev/v1alpha1",
        "//src/shared/cvmsgspb:cvmsgs_pl_go_proto",
        "//src/shared/k8s/metadatapb:metadata_pl_go_proto",
        "//src/utils",
        "//src/utils/testingutils",
        "@com_github_gofrs_uuid//:uuid",
        "@com_github_gogo_protobuf//proto",
        "@com_github_gogo_protobuf//types",
        "@com_github_nats_io_nats_go//:nats_go",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@io_k8s_api//batch/v1:batch",
        "@org_golang_google_grpc//:grpc",
        "@org_golang_google_grpc//credentials/insecure",
        "@org_golang_google_grpc//test/bufconn",
        "@org_golang_x_sync//errgroup",
    ],
)
